<?php
abstract class WooCommandCommand{
	//状态字符串数组
	private static $STATUS_STRINGS= array(
		'CMD_DEFAULT' => 0,
		'CMD_OK' => 1,
		'CMD_ERROR' => 2,
		'CMD_INSUFFICIENT_DATA' => 3
	);

	private $status = 0;


	final function __construct(){}

	function execute(WooControllerRequest $request){
		$this->status = $this->doExecute($request);
		$request->setCommand($this);
	}

	//返回当前Command对象的状态标记
	function getStatus(){
		return $this->status;
	}

	//用于将一个字符串转换为相关的数字
	static function statuses($str = 'CMD_DEFAULT'){
		if(empty($str)){
			$str = 'CMD_DEFAULT';
		}
		return self::$STATUS_STRINGS[$str];
	}

	abstract function doExecute(WooControllerRequest $request);
}